/*
========================================================================
 Name        : ExportContactsSelectDirContainer.h
 Author      : etouch.cc
 Copyright   : etouch.cc,All Right Reserved!
 Description : 
========================================================================
*/
#ifndef EXPORTCONTACTSSELECTDIRCONTAINER_H
#define EXPORTCONTACTSSELECTDIRCONTAINER_H

 
#include <coecntrl.h>
#include <AknsBasicBackgroundControlContext.h>
 
class MEikCommandObserver;		
class CAknSingleGraphicStyleListBox;
class CEikTextListBox;
class CEikLabel;
class CEikEdwin;
class RFs;
class CDir;
class TParse;
class CDirLinkList;

//#define Debug
//#define Write_Log

class CExportContactsSelectDirContainer : public CCoeControl
{
public: 
	enum TControls
	{	 
		EListBox,		
		EFileInputLabel,
		EFileInputEdit,
		EFileExtensionLabel,
		ELastControl
	};
	
	enum TListBoxImages
	{	 
		EListBoxFirstUserImageIndex	
	};
	
	enum TRootDrive
	{
		EPhoneDrive = 0,
		EMemoryCardDrive
	};
	
	enum TDriveAndPathActions
	{
		EDriveAndPathBackUp,
		EDriveAndPathOpen
	};
 
public:	 
	CExportContactsSelectDirContainer();
	static CExportContactsSelectDirContainer* NewL( const TRect& aRect, const CCoeControl* aParent,	MEikCommandObserver* aCommandObserver );
	static CExportContactsSelectDirContainer* NewLC( const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver );
	void ConstructL( const TRect& aRect,const CCoeControl* aParent, MEikCommandObserver* aCommandObserver );
	virtual ~CExportContactsSelectDirContainer();

public:
	// from CCoeControl
	TInt CountComponentControls() const;
	CCoeControl* ComponentControl( TInt aIndex ) const;
	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
	void HandleResourceChange( TInt aType );
	void HandlePointerEventL(const TPointerEvent& aPointerEvent);
	
public: 
	static void AddListBoxItemL( CEikTextListBox* aListBox,	const TDesC& aString );
	static RArray< TInt >* GetSelectedListBoxItemsLC( CEikTextListBox* aListBox );	
	static void DeleteSelectedListBoxItemsL( CEikTextListBox* aListBox );
	static void DeleteAllListBoxItemsL( CEikTextListBox* aListBox );
	CAknSingleGraphicStyleListBox* ListBox();
	static void CreateListBoxItemL( TDes& aBuffer, TInt aIconIndex,const TDesC& aMainText );
	void AddListBoxResourceArrayItemL( TInt aResourceId, TInt aIconIndex );
	void SetupListBoxIconsL();
	static CGulIcon* LoadAndScaleIconL( const TDesC& aFileName,
										TInt aBitmapId,
										TInt aMaskId,
										TSize* aSize,
									TScaleMode aScaleMode );
	TBool HandleMarkableListCommandL( TInt aCommand );
	TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
	
protected:	 
	void SizeChanged();
	void Draw( const TRect& aRect ) const;

private:
	TKeyResponse OfferUpKeyEvent(const TKeyEvent& aKeyEvent, TEventCode aType);
	TKeyResponse OfferDownKeyEvent(const TKeyEvent& aKeyEvent, TEventCode aType);
	
private:
	void InitializeControlsL();
	void LayoutControls();	
	static void RunGlobalNote( const TDesC* aOverrideText );
	
public:
	TBool   EnterDir();
	void    MakeDir(const TDesC &aDirName);
	TBool   BackToSuperiorDir();
	TDesC&  GetExportFileFullName();	 
	
private:
	TBool OpenDir(const TDesC &aMatchName, TUint anAttMask);
	TBool ReadDir(const TDesC &aMatchName,TUint anAttMask );
	void  RefreshDir();
	void  SetParse();
	void  FillListBox();  
	void  ChangeCBA();	
	void  InitializeLinkList();
	void  WriteToLog(const TDesC8& aDesC);
	TBool IfMMCCard();
	
private: 
	CEikLabel* 							iFileInputLabel;
	CEikLabel*							iFileExtensionLabel;
	CEikEdwin* 							iFileInputEdit;
	CAknSingleGraphicStyleListBox*      iListBox;
	CCoeControl* 						iFocusControl;
	MEikCommandObserver*				iCommandObserver;
	CAknsBasicBackgroundControlContext* iBgContext;	 

private:
	TRect  iInputEditRect;
	TRect  iListBoxRect;
	
private:
	RFs  				iFs;	  
	TParse				iParse;
	HBufC*         		iExportFileFullName;	 
	CDirLinkList*		iDirLinkList;
	CDir*				iDir;
	
};
				
#endif // EXPORTCONTACTSSELECTDIRCONTAINER_H
